var assert = require("assert")
var arrayUtils = require("arrayUtils")

var $ = exports

$.testAny = function() {
	assert.ok( [1].any(1) )
	assert.ok( ! [1].any(2) )
	assert.ok( [1,2].any(function(e){
		return e == 1
	}))
	assert.ok( ![1,2].any(function(e){
		return e > 3
	}))
}

$.testReduce = function() {
	var result = ["a","b","c"].reduce(function(acum, e) {
		return acum + e + e
	}, "0")
	
	assert.equal("0aabbcc", result)
}

$.testFlatten = function() {
	var flattened = ["a",["b",["c","d"]]].flatten()
	assert.equal("c", flattened[2])
}

$.testMap = function() {
	var mapped = [1,2].map(function(n) { return n*3 })
	assert.equal(3, mapped[0])
	assert.equal(6, mapped[1])
	assert.equal(2, mapped.length)
}

$.testIsArray = function() {
	assert.ok( arrayUtils.isArray([]) )
	assert.ok( !arrayUtils.isArray({}) )
	assert.ok( !arrayUtils.isArray(1) )
	assert.ok( !arrayUtils.isArray("string") )
	assert.ok( !arrayUtils.isArray(undefined) )
}